<?php
	class strPoseJump{
		// 初始化值
		private $imgSrc;
		private $imgArr;
		private $str;
		public $arry;


		public function __construct($file, $imgArr = '../public/file_upload/'){

			$this->imgSrc = $imgArr;
			$this->imgArr = array("image/png", "image/jpeg", "image/jpg", "image/gif");
			$this->str    = "qwertyuiopasdfghjklzxcvbnm1234567890";
			$this->arry   = array();

			$this->file_upload($file);
		}

		// 文件上传的处理
		public function file_upload($file){

			if(is_array($file['name'])){

				foreach($file['type'] as $key=>$val){

					// 判断文件上传的类型
					if(!in_array($file['type'][$key], $this->imgArr)){
						exit('文件类型不对，请重新！');
					}

					// 获取文件后缀名
					$imgPath = pathinfo($file['name'][$key]);

					$filePath = $this->imgSrc.substr(str_shuffle($this->str),mt_rand(0,strlen($this->str)-11), 10).'.'.$imgPath['extension'];

					$this->arry[] = $filePath;

					// 把文件从临时目录移动到新目录下
					move_uploaded_file($file['tmp_name'][$key], $filePath);	
				}
			}else{

				// 判断文件上传的类型
				if(!in_array($file['type'], $this->imgArr)){
					exit('文件类型不对，请重新！');
				}

				$imgPath = pathinfo($file['name']);

				$filePath = $this->imgSrc.substr(str_shuffle($this->str),mt_rand(0,strlen($this->str)-11), 10).'.'.$imgPath['extension'];

				$this->arry[] = $filePath;

				// 把文件从临时目录移动到新目录下
				move_uploaded_file($file['tmp_name'], $filePath);
			}
			return $this->arry;
		}
	}
?>